// 模块加载----------------------
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {AppRoutingModule} from './app-routing.module';
import {ButtonModule} from 'primeng/button';
import {FormsModule} from '@angular/forms';
import {InputTextModule} from 'primeng/inputtext';
import {DropdownModule} from 'primeng/dropdown';
import {TableModule} from 'primeng/table';
import {DialogModule} from 'primeng/dialog';
import {FileUploadModule} from 'primeng/fileupload';
import {HttpClientModule} from '@angular/common/http';
import {ConfirmationService, MessageService} from 'primeng/api';
import {BlockUIModule} from 'primeng/blockui';
import {TreeModule} from 'primeng/tree';
import {JwtModule} from '@auth0/angular-jwt';
import {ProgressSpinnerModule} from 'primeng/progressspinner';
import {OverlayPanelModule} from 'primeng/overlaypanel';
import {StepsModule} from 'primeng/steps';
// 服务加载----------------------
import {DeviceService} from './svc/device.svc';
import {AuthGuard} from './auth.guard';
import {HashLocationStrategy, LocationStrategy} from '@angular/common';

// 组件加载--------------
import {AppComponent} from './app.component';
import {HomeComponent} from './view-root/home/home.component';
import {AccordionModule} from 'primeng/accordion';
import {InputTextareaModule} from 'primeng/inputtextarea';
import {SystemInformationComponent} from './vs/system-information/system-information.component';
import {DeviceSettingComponent} from './vs/device-setting/device-setting.component';
import {BedSensorSettingsComponent} from './vs/bed-sensor-settings/bed-sensor-settings.component';

// 国际化
import {HttpClient} from '@angular/common/http';
import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import {CalibrationComponent} from './vs/bed-sensor-settings/calibration/calibration.component';
import {AdvancedSettingsComponent} from './vs/bed-sensor-settings/advanced-settings/advanced-settings.component';
import {DataCommunicationComponent} from './vs/device-setting/data-communication/data-communication.component';
import {AuthenticationComponent} from './vs/device-setting/authentication/authentication.component';
import {NetworkComponent} from './vs/device-setting/network/network.component';
import {FirmwareUpgradeComponent} from './vs/device-setting/firmware-upgrade/firmware-upgrade.component';
import {CardModule} from 'primeng/card';
import {MessageModule} from 'primeng/message';
import {ToastModule} from 'primeng/toast';

import {ListboxModule} from 'primeng/listbox';
import {MonitoringComponent} from './vs/monitoring/monitoring.component';
import {AlertNotificationComponent} from './vs/alert-notification/alert-notification.component';
import {MotionStatusComponent} from './vs/monitoring/motion-status/motion-status.component';
import {HeartRateComponent} from './vs/monitoring/heart-rate/heart-rate.component';
import {HeartRateVariabilityComponent} from './vs/monitoring/heart-rate-variability/heart-rate-variability.component';
import {RespirationRateComponent} from './vs/monitoring/respiration-rate/respiration-rate.component';
import {StrokeVolumeComponent} from './vs/monitoring/stroke-volume/stroke-volume.component';
import {ServiceComponent} from './vs/alert-notification/service/service.component';
import {ReceiversComponent} from './vs/alert-notification/receivers/receivers.component';
import {ToolbarModule} from "primeng/toolbar";

export function HttpLoaderFactory(http: HttpClient): any {
    return new TranslateHttpLoader(http, '/assets/i18n/', '.json');
}

export function tokenGetter(): any {
    return localStorage.getItem('token');
}

@NgModule({
    declarations: [
        AppComponent,
        HomeComponent,
        SystemInformationComponent,
        DeviceSettingComponent,
        BedSensorSettingsComponent,
        CalibrationComponent,
        AdvancedSettingsComponent,
        DataCommunicationComponent,
        AuthenticationComponent,
        NetworkComponent,
        FirmwareUpgradeComponent,

        MonitoringComponent,
        AlertNotificationComponent,
        MotionStatusComponent,
        HeartRateComponent,
        HeartRateVariabilityComponent,
        RespirationRateComponent,
        StrokeVolumeComponent,
        ServiceComponent,
        ReceiversComponent,
    ],
    imports: [
        BrowserModule,
        ButtonModule,
        AppRoutingModule,
        FormsModule,
        BrowserAnimationsModule,
        InputTextModule,
        DropdownModule,
        FileUploadModule,
        TableModule,
        DialogModule,
        HttpClientModule,
        BlockUIModule,
        AccordionModule,
        TreeModule,
        ProgressSpinnerModule,
        OverlayPanelModule,
        TranslateModule.forRoot({
            loader: {
                provide: TranslateLoader,
                useFactory: HttpLoaderFactory,
                deps: [HttpClient]
            }
        }),
        JwtModule.forRoot({
            config: {
                tokenGetter,
            }
        }),
        InputTextareaModule,
        CardModule,
        MessageModule,
        ToastModule,
        StepsModule,
        ListboxModule,
        ToolbarModule
    ],
    providers: [
        DeviceService,
        ConfirmationService,
        AuthGuard,
        MessageService,
        {provide: LocationStrategy, useClass: HashLocationStrategy},
       ],
    bootstrap: [AppComponent]
})
export class AppModule {
}
